package com.dailyblue.example.springcloud.consumer.ribbon.service.impl;

import com.dailyblue.example.springcloud.commons.util.JsonResult;
import com.dailyblue.example.springcloud.consumer.ribbon.service.ConsumerRibbonService;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;

@Service
public class ConsumerRibbonServiceImpl implements ConsumerRibbonService {
    @Resource
    private RestTemplate restTemplate;

    @Override
    public JsonResult a() {
        return restTemplate.getForObject("http://cloud-example-provider/provider/a", JsonResult.class);
    }

    @Override
    public JsonResult b(int a) {
        String uri = "http://cloud-example-provider/provider/b?a=" + a;
        return restTemplate.getForObject(uri, JsonResult.class);
    }

    @Override
    public JsonResult c(int a) {
        String uri = "http://cloud-example-provider/provider/c/" + a;
        return restTemplate.getForObject(uri, JsonResult.class);
    }
}
